<template>
  <div id="ContactUs">
    <div class="banner container-fuild text-center">积分兑换</div>
    <div class="container">
      <van-divider />

      <!-- <van-cell-group>
        <van-cell class="cus" v-for="(i,k) in list" 
        :key='k'
         :title="i.title" 
        :value="i.indir" 
        :label="time[k]"
        @click="go_xq(i)"
         />
      </van-cell-group> -->

      <van-row gutter='20'>
        <van-col span="12">
          <van-cell title="名称" :value="info.pname" />
          <van-cell title="简介" :value="info.pinfo" />
          <van-cell title="价格" :value="info.prices" />
        </van-col>
        <van-col span="12">
          <van-card>
            <template #tags>
                <div class="mbt">地址:</div>
              <van-cell-group>

                <van-field
                  v-model="gd.name"
                  label="姓名"
                  placeholder="请输入用户名"
                />
                <van-field
                  v-model="gd.phone"
                  label="电话"
                  placeholder="请输入电话"
                />
                 <van-field
                  v-model="gd.address"
                  label="地址"
                  placeholder="请输入用户名"
                />
                 <van-field
                  v-model="gd.mark"
                  label="备注"
                  placeholder="请输入用户名"
                />

              </van-cell-group>
              <van-button class="sub" @click="gd_sub" type="info">提交</van-button>
            </template>
          </van-card>
        </van-col>
      </van-row>

      <van-divider />
    </div>
  </div>
</template>
<script>
import { WOW } from "wowjs";
import BMap from "BMap";
export default {
  name: "JifenGood",
  data() {
    return {
      user: "",
      list: [],
      time: [],
      info: "",
      gd:{
          name:'',
          phone:'',
          address:'',
          mark:''

      },
    };
  },
  mounted() {
    let suer = JSON.parse(localStorage.getItem("user"));
    this.user = suer;
     let lg= localStorage.getItem('lg');
     if(!lg){
    this.$router.push('/login');
   }else{
    //  this.is_lg=true
   }
    console.log(this.user)
    let aa = this.$route.query.info;
    console.log("aa:", aa);
    this.info = aa;
    var wow = new WOW();
    wow.init();
    // this.get_konw();
  },
  methods: {
      gd_sub(){
          let {gd}=this;

          let data={
              uid:this.user[0].id,
              pid:this.info.id,
              names:gd.name,
              phones:gd.phone,
              address:gd.address,
              marks:gd.mark
          };
          if(!gd.name){
            alert('请输入名字');return;
          }
          if(!gd.phone){
            alert('请输入电话');return;
          }
          if(!gd.address){
            alert('请输入地址');return;
          }
        this.http.post('/products/jefenordermsg',data).then(res=>{
            alert(res.data.msg);
            console.log(res)
        })

          console.log('gd:',gd,'dd:',data);


      },
    //   go_xq(e){
    //       this.$router.push({path:'/konwxq',query:{info:e} })
    //   },
    timeTrans(date) {
      var date = new Date(date * 1000);
      var Y = date.getFullYear() + "-";
      var M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      var D =
        (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
      var h =
        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
      var m =
        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
        ":";
      var s =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      return Y + M + D + h + m + s;
    },

    get_konw() {
      let v = this;
      this.http.post("/products/getculmsg").then((res) => {
        console.log("知识库:", res);
        if (res.data.code == 1) {
          v.list = res.data.data;

          let dd = res.data.data;
          for (let i of dd) {
            let tt = v.timeTrans(i.createtime);
            v.time.push(tt);
          }
        } else {
          alert(res.data.msg);
        }
      });
    },
  },
};
</script>
<style scoped>
.sub{
    width: 20vw;
    margin-top: 20px;
}
.center {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  flex-direction: column;
}
.banner {
  color: #fff;
  font-size: 30px;
  height: 150px;
  line-height: 150px;
  background-image: url("../assets/img/banner_1.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: scroll;
  background-position: center center;
}
.ContactUs-container {
  padding: 80px 0;
  transition: all ease 0.5s;
  box-sizing: border-box;
}
#map {
  width: 100%;
  height: 365px;
}
.row {
  margin-right: 0;
  margin-left: 0;
}
@media screen and (max-width: 997px) {
  .ContactUs-container {
    padding: 20px 0;
  }
}
</style>

